package horarios;

/*Copyright [2011] [Marco Aurelio Pontes]

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 */

import java.util.Vector;

import net.sourceforge.floggy.persistence.FloggyException;
import net.sourceforge.floggy.persistence.PersistableManager;

public class Terminal extends Dados {

	private String nomeTerminal;
	private Vector listaOnibus = new Vector();

	// public static boolean terminalExiste(String nome) {
	// ObjectSet os = null;
	// try {
	// os = PersistableManager.getInstance().find(Terminal.class, null,
	// null);
	// for (int i = 0; i < os.size(); i++) {
	// Terminal terminal = (Terminal) os.get(i); // obtem as instancias
	// // do banco
	// if (terminal.getNome().equals(nome)) {
	// return true;
	// }
	//
	// }
	//
	// } catch (FloggyException ex) {
	//
	// }
	// return false;
	// }
	//
	// public static Terminal getTerminalByName(String nome) {
	// ObjectSet os = null;
	// try {
	// os = PersistableManager.getInstance().find(Terminal.class, null,
	// null);
	// for (int i = 0; i < os.size(); i++) {
	// Terminal terminal = (Terminal) os.get(i); // obtem as instancias
	// // do banco
	// if (terminal.getNome().equals(nome)) {
	// return terminal;
	// }
	//
	// }
	//
	// } catch (FloggyException ex) {
	//
	// }
	// return null;
	// }


	public void carrega(){
		Filtro filtro = new Filtro();
		filtro.setStringTerminal(this.getNomeTerminal());
		try {
			this.load(filtro);
		} catch (FloggyException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}		
	}
	
	
	public void setNomeTerminal(String nomeTerminal) {
		this.nomeTerminal = nomeTerminal;
	}

	public String getNomeTerminal() {
		return nomeTerminal;
	}

	public void setListaOnibus(Vector listaOnibus) {
		this.listaOnibus = listaOnibus;
	}

	public Vector getListaOnibus() {
		return listaOnibus;
	}
	
	public void adicionaOnibus(Onibus novoOnibus) {
		this.listaOnibus.addElement(novoOnibus);

	}
	
}